/*************************************************************
 * * Copyright (c) 2008-2010  Hillstonenet
 *
 * All Rights Reserved
 * 
 * This is the proprietary source code of Hillstonenet Company product HSM
 *
 * @author yan peng
 *
 * 2010-12-16 11:55:38
 * 2011-04-12 11:10 modify to Refactor
 * 2011-05-25 add login(String userName, String password, int flag) method for session handle logic
 * 
 ***************************************************************/
package com.eudi.springflex.facade.user;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.hillstone.hsm.common.exception.ExceptionMessage;
import com.hillstone.hsm.common.object.user.User;
import com.hillstone.hsm.common.util.ReturnValueObj;

@Component(value = "loginService")
public class LoginFacade {

	/**
	 * user login HSM
	 * 
	 * @param userName
	 * @param password
	 * @return
	 */
	public ReturnValueObj login(String userName, String password, String captcha) {
		ReturnValueObj returnValueObj = new ReturnValueObj();
		Map<String, List> map = new HashMap<String, List>();
		User user = loginInner(userName, password, captcha, false, true);
		List<User> userList = new ArrayList<User>();
		userList.add(user);
		map.put("userlist", userList);
		
		returnValueObj.setValue(map);
		
		return returnValueObj;
	}
	

	/**
	 * 获取radius配置信息
	 * @return
	 */
	public ReturnValueObj getRadiusServerInfo() {
		ReturnValueObj returnValueObj = new ReturnValueObj();
		try {
			returnValueObj.setSuccess(true);
			returnValueObj.setReturnValue(null);
		} catch(Exception e) {
			returnValueObj.setSuccess(false);
		}
		return returnValueObj;
	}

	/**
	 * User logOut HSM System,Record leaving time
	 * 
	 * @param userName
	 * @param password
	 */
	public ReturnValueObj logoff() {
		ReturnValueObj returnValueObj = new ReturnValueObj();
		return returnValueObj;
	}

	// ---------------------------------------------------------------------------------------
	/**
	 * 
	 * @param userName
	 * @param password
	 * @param flag
	 * @param changeSessionId
	 *            whether change sessionId with custom from http sessionId
	 * @return
	 * @throws ExceptionMessage
	 */
	@SuppressWarnings("static-access")
	private User loginInner(String userName, String password,String captcha,
			boolean clearSession, boolean changeSessionId)
			throws ExceptionMessage {
		User user = new User();
		return user;
	}

	/**
	 * invoke service layer component to login
	 */
	@SuppressWarnings("static-access")
	private int logoffInner() throws ExceptionMessage {
		int userId = 0;
		userId = 1;
		return userId;
	}
	
}